package com.hotel.controller;

import com.hotel.entity.Swiper;
import com.hotel.response.MessageUtils;
import com.hotel.response.RestResponse;
import com.hotel.service.SwiperService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 夏智力
 * @FileName SwiperController
 * @date 2021/6/22 19:23
 * @Software: IntelliJ IDEA
 */
@RestController
public class SwiperController {

    @Autowired
    private SwiperService swiperService;

    // 根据房间类型id查询图片路径
    @RequestMapping(path = "/swiper/list", method = RequestMethod.GET)
    public RestResponse getSwiperList(int typeId){
        List<Swiper> swipers = swiperService.selectByTypeId(typeId);
        return MessageUtils.success(swipers);
    }

    // 添加图片
    @RequestMapping(path = "/swiper/add", method = RequestMethod.POST)
    public void addSwiper(Swiper swiper) {
        swiperService.addSwiper(swiper);
    }


    // 根据id修改图片地址
    @RequestMapping(path = "/swiper/update", method = RequestMethod.POST)
    public void updateSwiperUrlById(int id, String url) {
        swiperService.updateSwiper(id, url);
    }

    @RequestMapping(path = "/swiper/update", method = RequestMethod.DELETE)
    public void deleteSwiper(int id) {
        swiperService.deleteSwiper(id);
    }

}
